﻿Imports System.Data.SqlClient
Public Class DanhSachNguoiDung

    Private Sub btnThem_Click(sender As System.Object, e As System.EventArgs) Handles btnThem.Click
        Me.Close()
        Dim frm As ThemNguoiDung = New ThemNguoiDung()
        frm.Show()
    End Sub

    Private Sub btnSua_Click(sender As System.Object, e As System.EventArgs) Handles btnSua.Click
        Dim TenDangNhap As String
        Dim MatKhau As String
        Dim row As Integer = Me.listView1.SelectedItems(0).Index
        TenDangNhap = Me.listView1.Items(row).SubItems(0).Text
        MatKhau = Me.listView1.Items(row).SubItems(1).Text
        Dim frm As SuaNguoiDung = New SuaNguoiDung(TenDangNhap, MatKhau)
        Me.Close()
        frm.Show()
    End Sub

    Private Sub btnXoa_Click(sender As System.Object, e As System.EventArgs) Handles btnXoa.Click
        Dim TenDangNhap As String
        Dim MatKhau As String
        Dim row As Integer = Me.listView1.SelectedItems(0).Index
        TenDangNhap = Me.listView1.Items(row).SubItems(0).Text
        MatKhau = Me.listView1.Items(row).SubItems(1).Text
        Dim con As SqlConnection = New SqlConnection()
        con.ConnectionString = KetNoi.str
        con.Open()
        Dim cmd As SqlCommand = New SqlCommand()
        cmd.Connection = con
        cmd.CommandText = "DELETE FROM QuanLyNguoiDung WHERE TenDangNhap='" + TenDangNhap + "' and MatKhau='" + MatKhau + "'"
        Dim result As DialogResult
        result = MessageBox.Show("Bạn Muốn Xoá Dữ Liệu Người Dùng Không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then
        End If
            {
        cmd.ExecuteNonQuery()
        con.Close()
        MessageBox.Show("Xoá Dữ Liệu Thành Công")
        Me.Close()
        Dim frm As DanhSachNguoiDung = New DanhSachNguoiDung()
        frm.Show()
    End Sub

    Private Sub btnThoat_Click(sender As System.Object, e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class